package a2_bellman_ford_test;

import static org.junit.Assert.*;

import org.junit.Test;

import a1_graph_lib.AIGraph;
import a1_graph_lib.AIGraphCounter;
import a1_reader.GraphReader;
import a2_bellman_ford.Bellman_Ford_Algorithmus;

public class Bellman_Ford_Test {

	static private final int MAX_INT = Integer.MAX_VALUE;

	@Test
	public void test_graph_gerichtet_1() {
		// der benutzte Graph heist test1
		//final String pfad = "C:\\Users\\Jonath\\Dropbox\\Mincraft Coder\\eclipse\\GKA_P\\src\\graphen\\test1";
		final String pfad = "C:\\Users\\Jonathan\\Desktop\\Neuer Ordner\\GKA_P\\src\\graphen\\test1";
		AIGraph graphI = new AIGraph();
		graphI = GraphReader.readGraph(graphI, pfad);
		AIGraphCounter graph = new AIGraphCounter(graphI);
		graph = Bellman_Ford_Algorithmus.bellmanFord(graph, 0, "0");
		System.out.println("Graph Pfad: " + pfad);
		System.out.println("ZugriffeLesenVerticis: " + graph.getZugriffeLesenVerticis());
		System.out.println("ZugriffeLesenKanten: " + graph.getZugriffeLesenEdges());
		System.out.println("ZugriffeLesenAtribute: " + graph.getZugriffeLesenAtribute());
		System.out.println("ZugriffeAendernAtribute: " + graph.getZugriffeAendernAtribute());
		System.out.println("ZugriffeAlle: " + graph.getZugriffeGraph());
		System.out.println();
		
		assertEquals(0, graph.getValV(0, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(0, "Vorgaenger"));
		assertEquals(10, graph.getValV(1, "Kosten"));
		assertEquals(0, graph.getValV(1, "Vorgaenger"));
		assertEquals(15, graph.getValV(2, "Kosten"));
		assertEquals(1, graph.getValV(2, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(3, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(3, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(4, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(4, "Vorgaenger"));
		assertEquals(19, graph.getValV(5, "Kosten"));
		assertEquals(2, graph.getValV(5, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(6, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(6, "Vorgaenger"));
		assertEquals(8, graph.getValV(7, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(7, "Kosten"));
		assertEquals(7, graph.getValV(8, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(8, "Kosten"));
		assertEquals(7, graph.getValV(9, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(9, "Kosten"));
		assertEquals(8, graph.getValV(10, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(10, "Kosten"));
	}

	@Test
	public void test_graph_ungerichtet_1() {
		//der benutzte Graph heist test2
		//final String pfad =  "C:\\Users\\Jonath\\Dropbox\\Mincraft Coder\\eclipse\\GKA_P\\src\\graphen\\test2";
		final String pfad = "C:\\Users\\Jonathan\\Desktop\\Neuer Ordner\\GKA_P\\src\\graphen\\test2";
		AIGraph graphI = new AIGraph();
		graphI = GraphReader.readGraph(graphI, pfad);
		AIGraphCounter graph = new AIGraphCounter(graphI);
		graph = Bellman_Ford_Algorithmus.bellmanFord(graph, 0, "0");
		System.out.println("Graph Pfad: " + pfad);
		System.out.println("ZugriffeLesenVerticis: " + graph.getZugriffeLesenVerticis());
		System.out.println("ZugriffeLesenKanten: " + graph.getZugriffeLesenEdges());
		System.out.println("ZugriffeLesenAtribute: " + graph.getZugriffeLesenAtribute());
		System.out.println("ZugriffeAendernAtribute: " + graph.getZugriffeAendernAtribute());
		System.out.println("ZugriffeAlle: " + graph.getZugriffeGraph());
		System.out.println();
		
		assertEquals(0, graph.getValV(0, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(0, "Vorgaenger"));
		assertEquals(10, graph.getValV(1, "Kosten"));
		assertEquals(0, graph.getValV(1, "Vorgaenger"));
		assertEquals(15, graph.getValV(2, "Kosten"));
		assertEquals(1, graph.getValV(2, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(3, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(3, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(4, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(4, "Vorgaenger"));
		assertEquals(19, graph.getValV(5, "Kosten"));
		assertEquals(2, graph.getValV(5, "Vorgaenger"));
		assertEquals(13, graph.getValV(6, "Kosten"));
		assertEquals(1, graph.getValV(6, "Vorgaenger"));
		assertEquals(0, graph.getValV(7, "Vorgaenger"));
		assertEquals(7, graph.getValV(7, "Kosten"));
		assertEquals(7, graph.getValV(8, "Vorgaenger"));
		assertEquals(11, graph.getValV(8, "Kosten"));
		assertEquals(7, graph.getValV(9, "Vorgaenger"));
		assertEquals(12, graph.getValV(9, "Kosten"));
		assertEquals(8, graph.getValV(10, "Vorgaenger"));
		assertEquals(16, graph.getValV(10, "Kosten"));
	}
	
	@Test
	public void test_graph_ungerichtet_negCircel_2() {
		// der benutzte Graph heist test3
		//final String pfad = "C:\\Users\\Jonath\\Dropbox\\Mincraft Coder\\eclipse\\GKA_P\\src\\graphen\\test3";
		final String pfad = "C:\\Users\\Jonathan\\Desktop\\Neuer Ordner\\GKA_P\\src\\graphen\\test3";
		AIGraph graphI = new AIGraph();
		graphI = GraphReader.readGraph(graphI, pfad);
		AIGraphCounter graph = new AIGraphCounter(graphI);
		graph = Bellman_Ford_Algorithmus.bellmanFord(graph, 0, "0");
		System.out.println("Graph Pfad: " + pfad);
		System.out.println("ZugriffeLesenVerticis: " + graph.getZugriffeLesenVerticis());
		System.out.println("ZugriffeLesenKanten: " + graph.getZugriffeLesenEdges());
		System.out.println("ZugriffeLesenAtribute: " + graph.getZugriffeLesenAtribute());
		System.out.println("ZugriffeAendernAtribute: " + graph.getZugriffeAendernAtribute());
		System.out.println("ZugriffeAlle: " + graph.getZugriffeGraph());
		System.out.println();
		
		assertEquals(MAX_INT, graph.getValV(0, "Kosten"));
		assertEquals(7, graph.getValV(0, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(1, "Kosten"));
		assertEquals(0, graph.getValV(1, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(2, "Kosten"));
		assertEquals(1, graph.getValV(2, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(3, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(3, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(4, "Kosten"));
		assertEquals(MAX_INT, graph.getValV(4, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(5, "Kosten"));
		assertEquals(2, graph.getValV(5, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(6, "Kosten"));
		assertEquals(1, graph.getValV(6, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(7, "Kosten"));
		assertEquals(8, graph.getValV(7, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(8, "Kosten"));
		assertEquals(7, graph.getValV(8, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(9, "Kosten"));
		assertEquals(7, graph.getValV(9, "Vorgaenger"));
		assertEquals(MAX_INT, graph.getValV(10, "Kosten"));
		assertEquals(8, graph.getValV(10, "Vorgaenger"));
	}
}
